//
//  ToDayViewController.m
//  iDaily Watch
//
//  Created by 老师先给我发 on 14-10-13.
//  Copyright (c) 2014年 Team 2 All rights reserved.
//

#import "ToDayViewController.h"
#import "ToDayModel.h"
#import "ModelSource.h"
#import "UIImageView+WebCache.h"
#import "SlideImageView.h"
#import "ContentViewController.h"

@interface ToDayViewController ()

@end

@implementation ToDayViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
     
    }
    return self;
}
- (id)init
{
    self = [super init];
    if (self) {
        CGRect rect = {{25,10},{275,345}};
        slideImageView = [[SlideImageView alloc]initWithFrame:rect ZMarginValue:5 XMarginValue:10 AngleValue:0.3 Alpha:1000];
        slideImageView.borderColor = [UIColor whiteColor];
        slideImageView.delegate = self;
    }
    return self;
}

- (void)loadView
{
    self.modelController = [NSMutableArray array];
    
    dispatch_queue_t globelMainQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
    dispatch_async(globelMainQueue, ^{
        
        ToDayModel * model = [[ToDayModel alloc]init];
        [model getDataFromBlock:^(NSMutableArray *dataSource) {
            self.modelController = dataSource;
            
            for(int i=0; i < 20; i++)
            {
                [slideImageView addImgURL:[self.modelController[i] cover_landscapeURL]];
            }
            [slideImageView setImageShadowsWtihDirectionX:2 Y:2 Alpha:0.7];
            [slideImageView reLoadUIview];
        }];
        
    });
    
    
    self.navigationController.title = @"ToDay";
    self.navigationController.navigationBar.translucent = NO;
    self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
    
    [super loadView];
    [self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"bg6.jpg"]]];
    [self.view addSubview:slideImageView];
    [self.view addSubview:clickLabel];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
 
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (void)SlideImageViewDidClickWithIndex:(int)index
{
    ContentViewController * vc = [[ContentViewController alloc]init];
    vc.modelArr = self.modelController;
    NSLog(@"%d", index);
    vc.pageTag = index;
    [self.navigationController pushViewController:vc animated:YES];
    [vc release];
}


@end
